-- card: 37379 from stack: in.5 -- bmap block id: 36823 -- flags: 0000 -- background id: 3858 -- name: MonitorCount ----- HyperTalk script ----- on HideObjects hide cd btn "Try It!" end HideObjects on ShowObjects show cd btn "Try It!" end ShowObjects -- part 1 (button) -- low flags: 00 -- high flags: A002 -- rect: left=82 top=185 right=219 bottom=175 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 8192 -- line height: 16 -- part name: Try it! ----- HyperTalk script ----- on mouseUp answer "This Mac has" && MonitorCount() && "monitors." end mouseUp -- part contents for background part 38 ----- text ----- 30/50 -- part contents for background part 20 ----- text ----- This XFCN returns the number of active (useable) monitors attached to the Mac. Calling syntax : MonitorCount() Returns: the number of monitors. -- part contents for background part 42 ----- text ----- unit monitorCount; {} {monitorCount()} { Check and report the number of monitors currenty attached. } {} {} { brought to you by: Anup Murarka Eric Carlson } { ALINK: SKEPTIC ALINK: cyNic } { CIS: 76004,3356 } {} { We are part of the Support Tools Development Group, } { Apple Computer, Inc. } {} { please DO NOT contack Mac DTS for support of this code! } {} { please DO contact the authors for support of this code! } {} { Send comments, bug reports, requests to any of the above } { E-mail addresses or to:} {} { (one of us) } { Apple Computer, Inc. } { 900 E. Hamilton, Ave. } { Campbell, CA 95008 } { M/S 72-L } {} { Copyright: © 1989, 1990 by Apple Computer, Inc., all rights reserved. } {} { written by Eric Carlson } { AppleLink: cyNic } { modification history } { Date Initials Comments } { ---- ------ --------------------------------------------------} { 9/1/89 ec first written } { 6/6/90 ec cleaned code, added comments } {} interface uses HyperXCMD; procedure main (paramPtr: XCmdPtr); implementation function askedForHelp (paramPtr: XCmdPtr; syntaxMsg: Str255; copyRightMsg: Str255): boolean; {} { check to see if the user sent a '?' or a '!' as } { the only parameter. if so we will respond with } { the calling syntax or the copyright/version info } { for this external } {} var firstStr: str255; begin askedForHelp := false; if paramPtr^.paramCount = 1 then begin ZeroToPas(paramPtr, paramPtr^.params[1]^, firstStr); { what is the first param? } if firstStr = '?' then begin paramPtr^.returnValue := PasToZero(paramPtr, syntaxMsg); askedForHelp := true end { asked for help } else if firstStr = '!' then begin paramPtr^.returnValue := PasToZero(paramPtr, copyRightMsg); askedForHelp := true end; { asked for copyright info } end; { one parameter passed } end; { function } function NumberToString (paramPtr: XCmdPtr; num: LONGINT): Str255; { use the toolbox call rather than HC's } var tempStr: str255; begin NumToString(num, tempStr); NumberToString := tempStr; end; procedure monitorCount (paramPtr: XCmdPtr); const UTableBase = $11C; screenActive = 15; { 1 if in use } var currGDevice: GDHandle; theSysEnv: SysEnvRec; envErr: OSErr; monitorNum: integer; copyRtStr, syntaxStr: str255; function TestDeviceAttribute (gdh: GDHandle; attribute: INTEGER): BOOLEAN; inline $AA2C; function GetDeviceList: GDHandle; inline $AA29; function GetGDevice: GDHandle; inline $AA32; begin syntaxStr := 'monitorCount()'; copyRtStr := '© 1989,1990 Apple Computer, Inc. v.1.0, by Eric Carlson.'; if askedForHelp(paramPtr, syntaxStr, copyRtStr) then exit(monitorCount); { just asking for help } monitorNum := 1; { assume that we'll fond just one monitor } envErr := SysEnvirons(1, theSysEnv); { call sysEnvirons to see about color QD } if envErr = noErr then if theSysEnv.hasColorQD then { only proceed if we have color QD } begin monitorNum := 0; currGDevice := GetDeviceList; { grab the first gDevice in the list } while (currGDevice <> nil) do { and step through the whole list } begin if TestDeviceAttribute(currGDevice, screenActive) then { see if the screen is active } monitorNum := monitorNum + 1; { another gDevice = another monitor } currGDevice := currGDevice^^.gdNextGD; { get the next one } end; end; paramPtr^.returnValue := PasToZero(paramPtr, NumberToString(paramPtr, monitorNum)); end; procedure main (paramPtr: XCmdPtr); begin monitorCount(paramPtr); end; end.